package com.test.springboot.springboot3aiollama1.service;

import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： liuziyang
 * @date： 2025/2/7-16:54
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@Service
public class AiService {
  private final OllamaChatModel chatModel;

  public AiService(OllamaChatModel chatModel) {
    this.chatModel = chatModel;
  }

  public String chat(String prompt) {
    ChatResponse response = chatModel.call(new Prompt("Spring Boot适合做什么?"));
    return response.getResults().get(0).getOutput().getText();
  }
}
